﻿using System;
using System.Net.Http;
using NC.Cather;

namespace NC.Service.CatchManager
{
    public class CatchService:ICatchService
    {
        public void Commit()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 获取UrlList容器
        /// </summary>
        /// <param name="url">网站地址</param>
        /// <param name="contentSelector">内容样式选择器</param>
        /// <param name="method">HttpMethodd</param>
        /// <returns>结果Html</returns>
        public string GetListContainer(string url, string contentSelector,HttpMethod method)
        {
            return CatherManager.GetHtml(url, contentSelector, method);
        }

        public string GetATagsByAccessToken(string accessToken)
        {
            return "";
        }

        public string GetNewsContentByAccessToken(string accessToken, string url)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 获取UrlList容器里a标签
        /// </summary>
        /// <param name="url">网站地址</param>
        /// <param name="contentSelctor">内容样式选择器</param>
        /// <param name="aSelector">a标签样式选择器</param>
        /// <param name="method">HttpMethod</param>
        /// <returns>结果Html</returns>
        public string GetListATags(string url, string contentSelctor, string aSelector,HttpMethod method)
        {
            var nodes = CatherManager.GetNodes(url, contentSelctor, aSelector, method);
            string resultHtml = string.Empty;
            foreach (var htmlNode in nodes)
            {
                resultHtml += htmlNode.OuterHtml;
            }
            return resultHtml;
        }
    }
}
